// cc.Mask.prototype.getGraphics = function () {
//     return this._graphics;
// };
// cc.Mask.prototype.drawRect = function (e, t, n, o) {
//     var i = this._graphics;
//     i.rect(e, t, n, o);
//     i.fill();
// };
// cc.Mask.prototype.drawRoundRect = function (e, t, n, o, i) {
//     var r = this._graphics;
//     r.roundRect(e, t, n, o, i);
//     r.fill();
// };
// var n = [];
// cc.Mask.prototype.drawCircle = function (e, t, o, i) {
//     if (void 0 === i) {
//         i = 64;
//     }
//     var r = this._graphics;
//     var a = (function (e, t, o) {
//         n.length = 0;
//         for (var i = (2 * Math.PI) / o, r = 0; r < o; ++r) {
//             var a = cc.v2(t.x * Math.cos(i * r) + e.x, t.y * Math.sin(i * r) + e.y);
//             n.push(a);
//         }
//         return n;
//     })(cc.v2(e, t), o, i);
//     for (var s = 0; s < a.length; ++s) {
//         var c = a[s];
//         0 === s ? r.moveTo(c.x, c.y) : r.lineTo(c.x, c.y);
//     }
//     r.close();
//     r.fill();
// };
// cc.Mask.prototype.clearDraw = function (e) {
//     if (void 0 === e) {
//         e = !1;
//     }
//     if (this._graphics) {
//         this._graphics.clear(e);
//     }
//     this._updateGraphics = function () {};
// };
// cc.Mask.prototype.drawPolygon = function (e) {
//     var t = this._graphics;
//     t.moveTo(e[0].x, e[0].y);
//     for (var n = 1; n < e.length; ++n) {
//         var o = e[n];
//         t.lineTo(o.x, o.y);
//     }
//     t.close();
//     t.fill();
// };
// cc.Node.prototype.setSwallowTouches = function (e) {
//     this._touchListener.setSwallowTouches(e);
// };


/**
 * 获取掩模的绘图接口
 * @return {cc.Graphics} 返回绘图实例
 */
cc.Mask.prototype.getGraphics = function () {
    return this._graphics;
};

/**
 * 绘制矩形
 * @param {number} x 矩形的起始x坐标
 * @param {number} y 矩形的起始y坐标
 * @param {number} width 矩形的宽度
 * @param {number} height 矩形的高度
 */
cc.Mask.prototype.drawRect = function (x, y, width, height) {
    let graphics = this._graphics;
    graphics.rect(x, y, width, height);
    graphics.fill();
};

/**
 * 绘制圆角矩形
 * @param {number} x 圆角矩形的起始x坐标
 * @param {number} y 圆角矩形的起始y坐标
 * @param {number} width 圆角矩形的宽度
 * @param {number} height 圆角矩形的高度
 * @param {number} radius 圆角的半径
 */
cc.Mask.prototype.drawRoundRect = function (x, y, width, height, radius) {
    let graphics = this._graphics;
    graphics.roundRect(x, y, width, height, radius);
    graphics.fill();
};

/**
 * 绘制圆形
 * @param {number} x 圆心的x坐标
 * @param {number} y 圆心的y坐标
 * @param {number} radius 圆的半径
 * @param {number} [segments=64] 圆的分段数
 */
cc.Mask.prototype.drawCircle = function (x, y, radius, segments = 64) {
    let graphics = this._graphics;
    let points = generateCirclePoints(cc.v2(x, y), radius, segments);
    points.forEach((point, index) => {
        index === 0 ? graphics.moveTo(point.x, point.y) : graphics.lineTo(point.x, point.y);
    });
    graphics.close();
    graphics.fill();
};

/**
 * 生成圆的点集
 * @param {cc.Vec2} center 圆心
 * @param {number} radius 半径
 * @param {number} segments 分段数
 * @return {cc.Vec2[]} 圆上的点集
 */
function generateCirclePoints(center, radius, segments) {
    const points = [];
    const angleStep = (2 * Math.PI) / segments;
    for (let i = 0; i < segments; ++i) {
        const angle = angleStep * i;
        points.push(cc.v2(radius * Math.cos(angle) + center.x, radius * Math.sin(angle) + center.y));
    }
    return points;
}

/**
 * 清除绘图
 * @param {boolean} [shouldClear=false] 是否清除
 */
cc.Mask.prototype.clearDraw = function (shouldClear = false) {
    if (this._graphics) {
        this._graphics.clear(shouldClear);
    }
    // 重置_updateGraphics为空函数，避免潜在问题
    this._updateGraphics = function () {};
};

/**
 * 绘制多边形
 * @param {cc.Vec2[]} vertices 多边形顶点数组
 */
cc.Mask.prototype.drawPolygon = function (vertices) {
    let graphics = this._graphics;
    graphics.moveTo(vertices[0].x, vertices[0].y);
    for (let i = 1; i < vertices.length; ++i) {
        graphics.lineTo(vertices[i].x, vertices[i].y);
    }
    graphics.close();
    graphics.fill();
};

/**
 * 设置触摸事件是否吞噬
 * @param {boolean} swallow 是否吞噬触摸事件
 */
cc.Node.prototype.setSwallowTouches = function (swallow) {
    this._touchListener.setSwallowTouches(swallow);
};